import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
import { rules } from '/@/utils/helper/validator';
import { h } from "vue";

export const columns: BasicColumn[] = [
  {
    title: '流程标题',
    dataIndex: 'subject',
    // width: 120,
  },
  {
    title: '流程类型',
    dataIndex: 'process_type',
    // width: 120,
  },
  {
    title: '申请人',
    dataIndex: 'applicant',
    // width: 120
  },
  {
    title: '在手时长',
    dataIndex: 'exist_time',
    // width: 120
  },
  {
    title: '发起时间',
    dataIndex: 'create_time',
    // width: 120
  },
];


export const searchFormSchema: FormSchema[] = [
  {
    label: '流程名称',
    field: 'subject',
    component: 'JInput',
    colProps: { span: 6 },
  },
  {
    label: '类型',
    field: 'selectedroles',
    component: 'JDictSelectTag',
    componentProps: {
      // stringToNumber: true,
      options: [
        { label: '显示委托代办', value: '1' },
        { label: '过滤委托待办', value: '2' },
      ]
    },
    colProps: { span: 6 },
  },
];

export const formSchema: FormSchema[] = [
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false,
  },
  {
    label: '字典名称',
    field: 'dictName',
    required: true,
    component: 'Input',
  },
  {
    label: '字典编码',
    field: 'dictCode',
    component: 'Input',
    dynamicDisabled: ({ values }) => {
      return !!values.id;
    },
    dynamicRules: ({ model, schema }) => rules.duplicateCheckRule('sys_dict', 'dict_code', model, schema, true),
  },
  {
    label: '描述',
    field: 'description',
    component: 'Input',
  },
];

export const dictItemColumns: BasicColumn[] = [
  {
    title: '名称',
    dataIndex: 'itemText',
    width: 80,
  },
  {
    title: '数据值',
    dataIndex: 'itemValue',
    width: 80,
  },
  {
    title: '字典颜色',
    dataIndex: 'itemColor',
    width: 80,
    align:'center',
    customRender:({ text }) => {
      return h('div', {
        style: {"background": text, "width":"18px","height":"18px","border-radius":"50%","margin":"0 auto"}
      })
    }
  },
];

export const dictItemSearchFormSchema: FormSchema[] = [
  {
    label: '名称',
    field: 'itemText',
    component: 'Input',
  },
  {
    label: '状态',
    field: 'status',
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: 'dict_item_status',
      stringToNumber: true,
    },
  },
];

